<?php

namespace Respect\Environment;

class CallbackEnv extends AbstractEnv implements EnvironmentableInterface
{

    protected $funcName = 'getenv';

    public function __construct($callback = 'getenv')
    {
        $this->funcName = $callback;
    }

    public function __invoke($varname)
    {
        $callback = $this->funcName;
        return $callback($varname);
    }

    public function offsetGet($varname)
    {
        $callback = $this->funcName;
        return $callback($varname);
    }

    public function __get($varname)
    {
        $callback = $this->funcName;
        return $callback($varname);
    }

}